<%@ page language="Java" import="java.util.*,descriptor.*,cv.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	CVListDescriptor cvList = (CVListDescriptor)request.getSession().getAttribute("CV");
	String error1 = (String)request.getAttribute("error1");
	String error2 = (String)request.getAttribute("error2");
%>

<%	
	String notif_delete = "";
	if(error1 != null)
	{
		notif_delete = "<p style=\"color:red; font-size: 10px;\">" + error1 + "<p>";
	}
%>

<html>
	<jsp:include page="StudentHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Student" />
	</jsp:include>
	<body OnLoad="showmenu(document.getElementById('smenu2'));">
		<jsp:include page="StudentPageHeader.jsp"></jsp:include>
		<div id="container">
			<jsp:include page="StudentMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Student - All CVs</h3>
				<div class="entry">
					<%= notif_delete %>
					<%
							int sizeList = cvList.getCVDescriptors().size(); 
							if(sizeList>0)
							{
					%>
					<table rules="all">
						<thead>
							<tr><th>CV Name</th><th>Authorization to publish</th><th>Actions</th></tr>
						</thead>
					<%
								for(int i=0; i<sizeList; i++)
								{
									String filename = cvList.getCVDescriptors().get(i).getFileName();
									boolean auth = cvList.getCVDescriptors().get(i).getPublishAuth();
									int cvID = cvList.getCVDescriptors().get(i).getID();
									String checked = "";
									String style = "";
									if(auth)
									{
										checked = "checked";
										style = "style=\"background-color: #66ee00;\"";
									}
					%>
						<tr <%= style %>>
							<td><%= filename %></td>
							<td><input type="checkbox" name="checkboxAuth" <%= checked %> disabled></td>
							<td>
								<form name="view<%= i %>" method="post">
									<input type="hidden" name="action" value="viewCV">
									<input type="hidden" name="cvID" value="<%= cvID %>">     
								</form> 
								<a href="javascript:document.view<%= i %>.submit();" title="View CV <%=  filename %>">View</a>
								<form name="change<%= i %>" method="post">
									<input type="hidden" name="action" value="changeAuthCV">
									<input type="hidden" name="cvID" value="<%= cvID %>">
									<input type="hidden" name="cvAuth" value="<%= auth %>">     
								</form> 
								<a href="javascript:document.change<%= i %>.submit();" title="Change <%=  filename %> Publish Authorization">Authorization</a>
								<form name="delete<%= i %>" method="post">
									<input type="hidden" name="action" value="deleteCV">
									<input type="hidden" name="cvID" value="<%= cvID %>"> 
									<input id="file<%= i %>" type="hidden" name="filename" value="<%= filename %>">    
								</form> 
								<a href="javascript:openDeleteWindow(document.getElementById('file<%= i %>'),document.delete<%= i %>);" title="Delete <%=  filename %>">Delete</a>
							</td>
						</tr>
				<%				}
				%>
					</table>
				<%
							}
							else
							{ 
								if(error2 != null)
				%>
									<p><%= error2 %></p>
								<form name="UploadCV" method="post">
									<input type="hidden" name="action" value="uploadCV">     
								</form> 
								<a href="javascript:document.UploadCV.submit();" title="Upload a CV">Upload</a>
								
				<%	 	
							} 
				%>
				</div>
	    	</div>
			<jsp:include page="StudentPageFooter.jsp"></jsp:include>
		</div>
	</body>
</html>